import requests
# 定义员工管理类
class IhrmEmpApi(object):
    # 定义添加员工方法
    @classmethod
    def add_emp(cls,header,req_data):
        resp = requests.post(url="https://ihrm-java.itheima.net/api/sys/user",
                             headers=header,
                             json=req_data)
        return resp
    # 定义查询员工方法
    @classmethod
    def query_emp(cls,emp_id,header):
        resp = requests.get(url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                             headers=header)
        return resp
    # 定义修改员工方法
    @classmethod
    def modify_emp(cls,emp_id,header,req_json):
        resp = requests.put(url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                             headers=header,
                             json=req_json)
        return resp
    # 定义删除员工方法
    @classmethod
    def del_emp(cls,emp_id,header):
        resp = requests.delete(url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                                headers=header)
        return resp
if __name__ == '__main__':
    req_headers = {"Authorization": "e6a8a11a-a32e-4b60-baa0-b7d4c6daf046", "Content-Type": "application/json"}
    req_json = {
        "username": "user001",
        "mobile": "13641252987",
        "workNumber": "7892"
    }
    # response = IhrmEmpApi.add_emp(req_headers,req_json)
    # print(response.json())
    # response = IhrmEmpApi.query_emp("1494919461403222016",req_headers)
    # print(response.json())
    # modify_data = {"username":"哈基米"}
    # response = IhrmEmpApi.modify_emp("1494919461403222016",req_headers,modify_data)
    # print(response.json())
    response = IhrmEmpApi.del_emp("1494919461403222016",req_headers)
    print(response.json())